<?php

use Biz\model\activity\CplRecord as mCplRecord;
use Biz\service\activity\CplRecord;

/**
 * @deprecated
 * 记录cpl 用户填写信息
 */
class RecordCplAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $page_id = $this->getRequest()->getPost('page_id');
        $module_id = $this->getRequest()->getPost('module_id');
        $name = $this->getRequest()->getPost('name');
        $phone = $this->getRequest()->getPost('phone');
        $area =  $this->getRequest()->getPost('area');
        $is_save =  $this->getRequest()->getPost('is_save' , 0);
        $uid = $this->uid ? : 0;
        //校验参数
        if(empty($page_id) || empty($module_id)  || empty($name) ||empty($phone) || empty($area)){
            throw new Exception('参数错误');
        }
        //去掉空格
        $phone = str_replace(" " , "" , $phone);
        $result = CplRecord::InsertData($page_id ,$module_id ,$name , $phone , $area ,$is_save,$uid);
        if($result){
            $this->setSuccess();
        }else{
            \Doraemon\tools\ActionLog::log($uid, mCplRecord::log(), \Doraemon\tools\ActionLog::ACTIVITY_PAGE);
            throw new Exception('提交失败');
        }
    }


}